/*
 *  Copyright (C) 2011 Hatsites
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.display.create;

import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.JRadioButton;
import org.myorg.shr.gui.swg.display.labelized.LbzDateChooserAbs;
import org.myorg.shr.gui.swg.display.labelized.LbzDateChooserVrt;
import org.myorg.shr.gui.swg.display.labelized.LbzTxfVrt;

/**
 *
 * @author Hatsites
 *
 * email: Hatsites_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 */

public class PnlIdtHmn extends PnlIdtAbs{
    public PnlIdtHmn(){
        super();
        this._ltfNom_ = new LbzTxfVrt("Nom",_LENGTH_TXF_);
        this._ltfPrenom1_ = new LbzTxfVrt("Prenom 1",_LENGTH_TXF_);
        this._ltfPrenom2_ = new LbzTxfVrt("Prenom 2",_LENGTH_TXF_);
        this._ltfPrenom3_ = new LbzTxfVrt("Prenom 3",_LENGTH_TXF_);
        this._bgrSexe_ = new ButtonGroup();
        this._rbnFemme_ = new JRadioButton("Femme");
        this._rbnHomme_ = new JRadioButton("Homme ");
        this._dateChooserNaissance_ = new LbzDateChooserVrt("Né le", 10);
        
    }

    @Override
    public boolean init(){

        if(!this._ltfNom_.init()){
            return false;
        }
        if(!this._ltfPrenom1_.init()){
            return false;
        }
        if(!this._ltfPrenom2_.init()){
            return false;
        }
        if(!this._ltfPrenom3_.init()){
            return false;
        }
       
        if(!this._dateChooserNaissance_.init()){
            return false;
        }

        this._bgrSexe_.add(this._rbnFemme_);
        this._bgrSexe_.add(this._rbnHomme_);

        javax.swing.GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);

        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                .addComponent(this._ltfNom_)
                .addComponent(this._ltfPrenom1_)
                .addComponent(this._ltfPrenom2_)
                .addComponent(this._ltfPrenom3_)
                .addComponent(this._dateChooserNaissance_)
                .addComponent(this._rbnHomme_)
                .addComponent(this._rbnFemme_)
             )
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(this._ltfNom_)
                .addComponent(this._ltfPrenom1_)
                .addComponent(this._ltfPrenom2_)
                .addComponent(this._ltfPrenom3_)
                .addGap(20,20,20)
                .addComponent(this._dateChooserNaissance_)
                .addComponent(this._rbnHomme_)
                .addComponent(this._rbnFemme_)
            )
        );
        return true;
    }
    
    public void destroy() {
        return;
    }

    public String getIdentiteNom(){
        return this._ltfNom_.getText();
    }

    public String getIdentitePrenom1(){
         return this._ltfPrenom1_.getText();
    }

    public String getIdentitePrenom2(){
         return _ltfPrenom2_.getText();
    }

    public String getIdentitePrenom3(){
         return this._ltfPrenom3_.getText();
    }

    public String getIdentiteDateNaissance() {
         return this._dateChooserNaissance_.getDate();
    }
    public String getIdentiteSexe() {
          if (this._rbnFemme_.isSelected()) {
             return "f";
         }
         else if (this._rbnHomme_.isSelected()) {
             return "h";
         }
         else {
             return "u";
         }
    }


    private final static int _LENGTH_TXF_ = 120;
    private LbzTxfVrt _ltfNom_;
    private LbzTxfVrt _ltfPrenom1_;
    private LbzTxfVrt _ltfPrenom2_;
    private LbzTxfVrt _ltfPrenom3_;
    private ButtonGroup _bgrSexe_;
    private JRadioButton _rbnFemme_;
    private JRadioButton _rbnHomme_;
    private LbzDateChooserAbs _dateChooserNaissance_;
}
